package cn.fz.ssedemo.utils;

/**
 * 线程局部变量上下文工具类
 */
public class ContextUtils {
    public static final ThreadLocal<Integer> adminIdThreadLocal = new ThreadLocal<>();

    // 保存当前登陆的用户id
    public static void setCurrentId(Integer id) {
        adminIdThreadLocal.set(id);
    }

    // 获取当前登陆的用户id
    public static Integer getCurrentId() {
        return adminIdThreadLocal.get();
    }

    // 移除当前登陆的用户id
    public static void removeCurrentId() {
        adminIdThreadLocal.remove();
    }
}
